package com.itfenghuang.day13;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

// TCP协议  服务端
public class A08_TCPServer {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10086);
        Socket socket = ss.accept();
        InputStream is = socket.getInputStream();
        byte[] bys=new byte[1024];
        int i = is.read(bys);// i 读取的数据的字节个数 bys读取的数据
        System.out.println(new String(bys,0,i));
        OutputStream os = socket.getOutputStream();
        os.write(bys,0,i);
        ss.close();
    }
}
